<?php

namespace App\Service\UserCenter;

use App\Constants\ErrorCode;
use App\Model\HostApplyLog;
use App\Model\UserProfile;
use App\Service\BaseService;

/**
 * 开通个人技能（声优申请）
 */
class HostApplyService extends BaseService
{
    public function handle()
    {
        $userId = $this->getUserId();
        $info['wechat_account'] = $this->request->input('wechat_account', '');
        $info['skills'] = $this->request->input('skills', '');
        $check = HostApplyLog::checkRecord($userId);
        if ($check) {
            return $this->setError(ErrorCode::HOST_APPLY_ING, '你提交的申请正在审核中，请耐心等待~');
        }
        //更新基本资料
        $ret = UserProfile::updateInfo($userId, $info);
        //添加申请记录
        $result = HostApplyLog::addRecord($userId, $info['skills'], $info['wechat_account']);
        return ['result' => 1];
    }
}
